<?php
include('header.php');
?>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="traveler.js"></script>
<div id=""global>
    <div class="gauche">
        <div id="trip_form">
            <form>
                <p style="padding:10px"><b>Itinerary:</b>
                <pre>
            Date <input type="text" id="departure_date" ><br/>
       Departure <input type="text" id="departure_addr" style=" width:200px" title="Departure address to geocode"><br/>
         Arrival <input type="text" id="arrival_addr" style=" width:200px" title="Arrival address to Geocode"><br/>
                 <button id="route_btn" type="button">Trace</button>
                </pre>
                </p>
            </form>
        </div>
        <div>
            <form>
                <p><b>Please leave a comment on your past trips with us</b></p>
                <p>Message:&nbsp;
                    <textarea id="comment" cols=60 rows=5></textarea><br/>
                    <button id="comment_btn" type="button">Send</button>
                </p>
            </form>
        </div>
        <div>
            <p>Past comments:
            <ul>
                <?php
                include('db_connect.php');
                $req = 'SELECT comment FROM comments';
                $res = mysql_query($req);
                mysql_close();
                while ($rec = mysql_fetch_assoc($res)) {
                    echo('<li>' . htmlentities($rec['comment']) . '</li>');
                }
                ?>
            </ul>
        </div>
        <div>
            <p>Please leave us some picture of your trips with us</p>
            <input id="image_file" type="file" size="100" />
            <progress id="progress"></progress>
            <p>View past pictures of trips <a href="../pics">here</a></p>
        </div>
    </div>
    <div class="droite">
        <div id="service_booking">
            <table id="car_rental">
                <caption>Car rental</caption>
                <thead>
                    <tr>
                        <th>&nbsp;</th>
                        <th>Place</th>
                        <th>Description</th>
                        <th>Contact</th>
                        <th>Price</th>
                    </tr>
                </thead>
                <tbody>
                    <?php
                    include('db_connect.php');
                    $req1 = 'SELECT * FROM services WHERE type = "car" ORDER BY price';
                    $res1 = mysql_query($req1) or die('Unable to retrieve services');
                    $i = 0;
                    while ($rec = mysql_fetch_assoc($res1)) {
                        $i++;
                        $service_id = $rec['id'];
                        $loc = htmlentities($rec['location']);
                        $descr = htmlentities($rec['description']);
                        $price = $rec['price'];
                        $req2 = 'SELECT name FROM providers WHERE id = "' . $rec['provider_id'] . '"';
                        $res2 = mysql_query($req2) or die('Unable to retrieve contact name');
                        $row = mysql_fetch_assoc($res2);
                        $provider = htmlentities($row['name']);
                        echo('<tr><td><button type="button" onclick="book_service(\'car\', ' .
                        $i . ');">Book!</button></td><td>' . $loc . '</td><td>' . $descr .
                        '</td><td>' . $provider . '</td><td>$' . $price . '</td></tr>');
                    }
                    mysql_close();
                    ?>
                </tbody>
            </table>
            <table id="hotel_reserv">
                <caption>Hotel reservation</caption>
                <thead>
                    <tr>
                        <th>&nbsp;</th>
                        <th>Place</th>
                        <th>Description</th>
                        <th>Contact</th>
                        <th>Price</th>
                    </tr>
                </thead>
                <tbody>
                    <?php
                    include('db_connect.php');
                    $req3 = 'SELECT * FROM services WHERE type = "hotel" ORDER BY price';
                    $res3 = mysql_query($req3) or die('Unable to retrieve services');
                    $j = 0;
                    while ($rec = mysql_fetch_assoc($res3)) {
                        $j++;
                        $service_id = $rec['id'];
                        $loc = htmlentities($rec['location']);
                        $descr = htmlentities($rec['description']);
                        $price = $rec['price'];
                        $req4 = 'SELECT name FROM providers WHERE id = "' . $rec['provider_id'] . '"';
                        $res4 = mysql_query($req4) or die('Unable to retrieve contact name');
                        $row = mysql_fetch_assoc($res4);
                        $provider = htmlentities($row['name']);
                        echo('<tr><td><button type="button" onclick="book_service(\'hotel\', ' .
                        $j . ');">Book!</button></td><td>' . $loc . '</td><td>' . $descr .
                        '</td><td>' . $provider . '</td><td>$' . $price . '</td></tr>');
                    }
                    mysql_close();
                    ?>
                </tbody>
            </table>
            <table id="food_reserv">
                <caption>Restaurants</caption>
                <thead>
                    <tr>
                        <th>&nbsp;</th>
                        <th>Place</th>
                        <th>Description</th>
                        <th>Contact</th>
                        <th>Price</th>
                    </tr>
                </thead>
                <tbody>
                    <?php
                    include('db_connect.php');
                    $req5 = 'SELECT * FROM services WHERE type = "food" ORDER BY price';
                    $res5 = mysql_query($req5) or die('Unable to retrieve services');
                    $k = 0;
                    while ($rec = mysql_fetch_assoc($res5)) {
                        $k++;
                        $service_id = $rec['id'];
                        $loc = htmlentities($rec['location']);
                        $descr = htmlentities($rec['description']);
                        $price = $rec['price'];
                        $req6 = 'SELECT name FROM providers WHERE id = "' . $rec['provider_id'] . '"';
                        $res6 = mysql_query($req6) or die('Unable to retrieve contact name');
                        $row = mysql_fetch_assoc($res6);
                        $provider = htmlentities($row['name']);
                        echo('<tr><td><button type="button" onclick="book_service(\'food\', ' .
                        $i . ');">Book!</button></td><td>' . $loc . '</td><td>' . $descr .
                        '</td><td>' . $provider . '</td><td>$' . $price . '</td></tr>');
                    }
                    mysql_close();
                    ?>
                </tbody>
            </table>
        </div>
        <div id="trip_summary">
            <p>
            <ul id="booked_services">Booked services:</ul>
            </p>
            <p>
                <span>Total price (USD):&nbsp;</span>
                <span id="total_price"></span>
                <span>
                    <button type="button" onclick="location.href = 'validate_payment.php';">Validate</button>
                </span>
            </p>
        </div>
        <div id="road_map"></div>
        <div id="trip_route"></div>
    </div>
</div>
<noscript>
<p>Attention : </p>
<p>Afin de pouvoir utiliser Google Maps, JavaScript doit être activé.</p>
<p>Or, il semble que JavaScript est désactivé ou qu'il ne soit pas supporté par votre navigateur.</p>
<p>Pour afficher Google Maps, activez JavaScript en modifiant les options de votre navigateur, puis essayez à nouveau.</p>
</noscript>
</body>
</html>